package com.sun.showcase.controller.mall;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

import com.sun.showcase.biz.mall.service.MemberCashApplyService;
import com.sun.showcase.pojo.DataGrid;
import com.sun.showcase.pojo.Result;
import com.sun.showcase.client.domain.mall.MemberCashApply;
import com.sun.showcase.client.query.mall.MemberCashApplyQuery;

@Controller
@RequestMapping(value="/mall/memberCashApply") 
public class MemberCashApplyController{
	
	@Autowired
	private MemberCashApplyService memberCashApplyService;
	
	private Result result = new Result();
	/**
	 * 跳转到MemberCashApply管理页面
	 * 
	 * @return
	 */
	@RequestMapping(value="goMemberCashApply")
	public String goMemberCashApply() {
		return "mall/memberCashApply";
	}
	/**
	 * 跳转到MemberCashApply新增页面
	 * 
	 * @return
	 */
	@RequestMapping(value="handleMemberCashApply")
	public String handleMemberCashApply(@RequestParam(value="id",required=false) Long id ,ModelMap map) {
		return "mall/memberCashApply_rowEdit";
	}

	/**
	 * 跳转到查看desc页面
	 * 
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="showDesc")
	public MemberCashApply showDesc(MemberCashApplyQuery memberCashApplyQuery) {
		return memberCashApplyService.get(memberCashApplyQuery);
	}

	/**
	 * 获得分页数据表格
	 */
	@ResponseBody
	@RequestMapping(value = "/datagrid")
	public DataGrid datagrid(MemberCashApplyQuery memberCashApplyQuery) {
		return memberCashApplyService.datagrid(memberCashApplyQuery);
	}
	

	/**
	 * 添加一个MemberCashApply
	 */
	@ResponseBody
	@RequestMapping(value="add")
	public Result add(MemberCashApplyQuery memberCashApplyQuery) {
		memberCashApplyService.add(memberCashApplyQuery);
		result.setSuccess(true);
		result.setMsg("添加成功！");
		return result;
	}

	/**
	 * 编辑MemberCashApply
	 */
	@ResponseBody
	@RequestMapping(value="edit")
	public Result edit(MemberCashApplyQuery memberCashApplyQuery) {
		memberCashApplyService.update(memberCashApplyQuery);
		result.setSuccess(true);
		result.setMsg("编辑成功！");
		return result;
	}

	/**
	 * 物理删除MemberCashApply
	 */
	@ResponseBody
	@RequestMapping(value="delete")
	public Result delete(MemberCashApplyQuery memberCashApplyQuery) {
		memberCashApplyService.delete(memberCashApplyQuery.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
	
	/**
	 * 逻辑删除MemberCashApply
	 */
	@ResponseBody
	@RequestMapping(value="deletePt")
	public Result deletePt(MemberCashApplyQuery memberCashApplyQuery) {
		memberCashApplyService.deletePt(memberCashApplyQuery.getIds());
		result.setSuccess(true);
		result.setMsg("删除成功！");
		return result;
	}
	/**
	 * 全部数据MemberCashApply
	 */
	@ResponseBody
	@RequestMapping(value="listAll")
	public Result listAll(MemberCashApplyQuery memberCashApplyQuery) {
		List<MemberCashApplyQuery> list = memberCashApplyService.listAll(memberCashApplyQuery);
		result.setSuccess(true);
		result.setMsg("成功！");
		result.setData(list);
		return result;
	}
}
